package com.wwj.auction.admin.controller;


import com.wwj.auction.admin.entity.vo.PageModel;
import com.wwj.auction.admin.entity.vo.WithdrawVo;
import com.wwj.auction.admin.service.WithdrawService;
import com.wwj.auction.common.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wwj
 * @since 2021-08-25
 */
@RestController
@RequestMapping("/admin/withdraw")
public class WithdrawController {

    @Autowired
    private WithdrawService withdrawService;

    /**
     * 分页查询提现内容
     *
     * @param page
     * @param limit
     * @param keyword
     * @return
     */
    @GetMapping("/list/{page}/{limit}")
    public R list(
            @PathVariable("page") Integer page,
            @PathVariable("limit") Integer limit,
            @RequestParam(value = "keyword", required = false) String keyword) {
        PageModel<WithdrawVo> pageModel = withdrawService.list(page, limit, keyword);
        return R.ok().data("pageModel", pageModel);
    }

    /**
     * 修改提现申请的状态
     *
     * @param id
     * @param status
     * @return
     */
    @GetMapping("/change/status/{id}/{status}")
    public R changeStatus(
            @PathVariable("id") Integer id,
            @PathVariable("status") Integer status) {
        withdrawService.changeStatus(id, status);
        return R.ok().message("操作成功");
    }
}

